package example.vo;

import lombok.Data;

import java.io.Serializable;

/**
 * @author guoQ.z
 * @date 2020/12/15 17:04
 * TODO
 */
@Data
public class ResponseEntity implements Serializable {
    public static final Integer SUCCESS_CODE = 200;
    public static final String SUCCESS_MESSAGE = "success";
    public static final Integer FAILED_CODE = 500;
    public int status;
    public String message;
    public Object data;

    public ResponseEntity(Integer status, String message, Object data) {
        this.status = status;
        this.message = message;
        this.data = data;
    }

    public ResponseEntity(Integer status, String message) {
        this.status = status;
        this.message = message;
    }

    public static ResponseEntity success(Object data) {
        return new ResponseEntity(ResponseEntity.SUCCESS_CODE, "success", data);
    }

    public static ResponseEntity fail(int status, String message) {
        return new ResponseEntity(status, message);
    }

    public static ResponseEntity fail(String message) {
        return new ResponseEntity(ResponseEntity.FAILED_CODE, message);
    }
}
